Skip to content

Add a symbolize transformer #7307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 17, 2025
Merged

Add a symbolize transformer #7307

merged 5 commits into from
May 17, 2025

Conversation

babacry
Copy link
Collaborator

@babacry babacry commented Apr 30, 2025

Symbolizes single qubit gates by tags.

Example:
Input:

        0: ───X[phxz_0]───@───Y[phxz_1]───X───
                          │
        1: ───────────────@───────────────────

$ cirq.symbolize_single_qubit_gates_by_indexed_tags(c, tag_prefix="phxz")
Output:

        0: ───PhXZ(a=a0,x=x0,z=z0)───@───PhXZ(a=a1,x=x1,z=z1)───X───
                                     │
        1: ──────────────────────────@──────────────────────────────

where, a0,x0,z0,a1,x1,z1 are symbols.

Context: to be used in #6994.

Copy link

codecov bot commented Apr 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.67%. Comparing base (716549e) to head (059b5f2).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7307   +/-   ##
=======================================
  Coverage   98.67%   98.67%           
=======================================
  Files        1111     1113    +2     
  Lines       97012    97058   +46     
=======================================
+ Hits        95729    95775   +46     
  Misses       1283     1283           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@babacry babacry force-pushed the symbolize branch 2 times, most recently from 1d6daf6 to 6d50406 Compare April 30, 2025 20:43
@babacry babacry removed the request for review from 95-martin-orion May 1, 2025 01:54
@babacry
Copy link
Collaborator Author

babacry commented May 1, 2025

@NoureldinYosri , phxz symbolizer transformer! Could you help review?

Copy link
Collaborator

@NoureldinYosri NoureldinYosri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall looks good but lets make the tag a class instead of a string, for example

@attrs.frozen
class SymbolizeTag:
    prefix: str

@babacry babacry force-pushed the symbolize branch 2 times, most recently from 65fa09f to 5b20dcc Compare May 8, 2025 04:57
@babacry
Copy link
Collaborator Author

babacry commented May 8, 2025

overall looks good but lets make the tag a class instead of a string, for example

@attrs.frozen
class SymbolizeTag:
    prefix: str

Good point, done.

@babacry babacry requested a review from NoureldinYosri May 8, 2025 05:17
Copy link
Collaborator

@NoureldinYosri NoureldinYosri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM%nit

Copy of the transformed input circuit.
"""

if not symbolize_tag.prefix:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets move this to the constructor of the tag, see the other comment


@attr.frozen
class SymbolizeTag:
prefix: str
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
prefix: str
prefix: str = attrs.field(validator=lambda s: len(s) > 0)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@babacry babacry added this pull request to the merge queue May 17, 2025
Merged via the queue into quantumlib:main with commit 4e12cbf May 17, 2025
35 checks passed
@babacry babacry deleted the symbolize branch May 17, 2025 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: M 50< lines changed <250
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants